using System;
using CodePlex.DnD4eCampaignManager.DnD4e.Interfaces;

namespace CodePlex.DnD4eCampaignManager.DnD4e
{
    public class Defenses : IDefenses, IEquatable<Defenses>
    {
        public int DefenseArmorClass { get; set; }
        public int DefenseFortitude { get; set; }
        public int DefenseReflex { get; set; }
        public int DefenseWillpower { get; set; }

        public override bool Equals(object obj)
        {
            if ( ReferenceEquals(null, obj) )
            {
                return false;
            }
            if ( ReferenceEquals(this, obj) )
            {
                return true;
            }
            if ( obj.GetType() != typeof ( Defenses ) )
            {
                return false;
            }
            return Equals((Defenses) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = DefenseArmorClass;
                result = ( result * 397 ) ^ DefenseFortitude;
                result = ( result * 397 ) ^ DefenseReflex;
                result = ( result * 397 ) ^ DefenseWillpower;
                return result;
            }
        }

        public bool Equals(Defenses other)
        {
            if ( ReferenceEquals(null, other) )
            {
                return false;
            }
            if ( ReferenceEquals(this, other) )
            {
                return true;
            }
            return other.DefenseArmorClass == DefenseArmorClass && other.DefenseFortitude == DefenseFortitude && other.DefenseReflex == DefenseReflex &&
                   other.DefenseWillpower == DefenseWillpower;
        }

        public static bool operator ==(Defenses left, Defenses right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(Defenses left, Defenses right)
        {
            return !Equals(left, right);
        }
    }
}